package com.smartwebx.fr.bean;

import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;

import com.google.common.collect.Iterables;

/**
 * 存储过程类
 * 
 * @author XX
 * 
 */
public class ProcResultUtil {
	

	private String callSql;
	private String funName;
	private Map<String, String> nameDbType;
	private Integer returnType;
	private Boolean hasHeader;
	private List<List<String>> result;
	private List<ColumnInfo> columnInfos;
	
	public List<ColumnInfo> getColumnInfos() {
		return columnInfos;
	}

	public void setColumnInfos(List<ColumnInfo> columnInfos) {
		this.columnInfos = columnInfos;
	}
	
	public String getCallSql() {
		return callSql;
	}

	public void setCallSql(String callSql) {
		this.callSql = callSql;
	}

	public String getFunName() {
		return funName;
	}

	public void setFunName(String funName) {
		this.funName = funName;
	}

	public Map<String, String> getNameDbType() {
		return nameDbType;
	}

	public void setNameDbType(Map<String, String> nameDbType) {
		this.nameDbType = nameDbType;
	}

	public Integer getReturnType() {
		return returnType;
	}

	public void setReturnType(Integer returnType) {
		this.returnType = returnType;
	}

	public void setResult(List<List<String>> result) {
		this.result = result;
	}

	public List<List<String>> getResult() {
		return result;
	}

	public void setHasHeader(Boolean hasHeader) {
		this.hasHeader = hasHeader;
	}
	
	public Boolean getHasHeader(){
		return hasHeader;
	}

	public boolean isEmpty() {
		boolean has = false;
		int resultFirstSize = Iterables.size(result);
		if (hasHeader) {// 有表头
			if (resultFirstSize > 1) {
				has = true;
			}
		} else {// 无表头
			if (resultFirstSize == 1) {
				List<String> needResult = Iterables.get(result, 1);
				if (!StringUtils.equals("/", needResult.get(0))) {
					has = true;
				}
			} else if (resultFirstSize > 1) {
				has = true;
			}
		}

		return has;
	}
}
